#ifndef _WORDS_QUEUE_H_
#define _WORDS_QUEUE_H_

#include "grate_constants.h"
#include "input_data.h"

// Cyclic queue that stores the words to be considered
struct words_queue{
  static const int MIN_WORDS_QUEUE_SIZE = 1 << 10;
  int size; // Queue size in bytes
  bool long_mask; // If true, 2 symbols per byte, otherwise 4 symbols per byte
  char * letters;
  i64 qbeg;
  i64 qend;
  words_queue (int _size, bool _long_mask);
  virtual ~words_queue();

  const bool is_empty() const;
  const i64 get_number_of_letters() const; // Returns the number of letters in the queue

  void inc_index (i64 &i);
  const bool is_index(i64 &i) const; // Returns true if qbeg == i

  const bool push_symbol (char ch); // Pushes a symbol, returns false if queue is full
  const bool push_marker (i64 &mpos); // Inserts a marker and returns its position in mpos, returns false if queue is full
  const bool push_word(const char * word, int type); // Pushes a word and its type (0-nothing, 1-"XX", 2-"XXY"), returns false if queue is full
  const char peek_symbol() const; // Returns the first symbol in the queue
  const char pop_symbol(); // Retrieves the first symbol from the queue
};

//void create_words_queue(input_data & INPUT, int size, words_queue * WORDS_QUEUE);
words_queue * create_words_queue(input_data & INPUT, int size);

#endif
